package com.itheima.utils;

import com.itheima.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = {Exception.class})
    public Result handlerException(Exception exception){
        exception.printStackTrace();
        return Result.error("服务器异常，请重新再试试！");
    }

    @ExceptionHandler(value = {NotNullException.class})
    public Result handlerNotNullException(RuntimeException runtimeException){
        runtimeException.printStackTrace();
        return Result.error(runtimeException.getMessage());
    }


}
